'use strict';

/**
 * @description 角色和菜单关系表模型
 * */
module.exports = app => {
  const { INTEGER } = app.Sequelize;

  const UserRelation = app.model.define('userRelation', {
    uid: {
      type: INTEGER,
      allowNull: false,
      comment: '用户id',
    },
    followId: {
      type: INTEGER,
      allowNull: false,
      comment: '被关注的id',
    },
  });

  UserRelation.associate = () => {
    app.model.UserRelation.belongsTo(app.model.User, {
      foreignKey: 'uid',
      as: 'User',
    });
    app.model.UserRelation.belongsTo(app.model.User, {
      foreignKey: 'followId',
      as: 'followUser',
    });
  };

  return UserRelation;
};
